﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: 2011年7月5日 11:37:43
// Code is generated using templates: SD.TemplateBindings.Linq
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using SD.LLBLGen.Pro.LinqSupportClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

using CARMSData;
using CARMSData.DaoClasses;
using CARMSData.EntityClasses;
using CARMSData.FactoryClasses;
using CARMSData.HelperClasses;
using CARMSData.RelationClasses;

namespace CARMSData.Linq
{
	/// <summary>Meta-data class for the construction of Linq queries which are to be executed using LLBLGen Pro code.</summary>
	public partial class LinqMetaData : ILinqMetaData
	{
		#region Class Member Declarations
		private ITransaction _transactionToUse;
		private FunctionMappingStore _customFunctionMappings;
		private Context _contextToUse;
		#endregion
		
		/// <summary>CTor. Using this ctor will leave the transaction object to use empty. This is ok if you're not executing queries created with this
		/// meta data inside a transaction. If you're executing the queries created with this meta-data inside a transaction, either set the Transaction property
		/// on the IQueryable.Provider instance of the created LLBLGenProQuery object prior to execution or use the ctor which accepts a transaction object.</summary>
		public LinqMetaData() : this(null, null)
		{
		}
		
		/// <summary>CTor. If you're executing the queries created with this meta-data inside a transaction, pass a live ITransaction object to this ctor.</summary>
		/// <param name="transactionToUse">the transaction to use in queries created with this meta-data</param>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(ITransaction transactionToUse) : this(transactionToUse, null)
		{
		}
		
		/// <summary>CTor. If you're executing the queries created with this meta-data inside a transaction, pass a live ITransaction object to this ctor.</summary>
		/// <param name="transactionToUse">the transaction to use in queries created with this meta-data</param>
		/// <param name="customFunctionMappings">The custom function mappings to use. These take higher precedence than the ones in the DQE to use.</param>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(ITransaction transactionToUse, FunctionMappingStore customFunctionMappings)
		{
			_transactionToUse = transactionToUse;
			_customFunctionMappings = customFunctionMappings;
		}
		
		/// <summary>returns the datasource to use in a Linq query for the entity type specified</summary>
		/// <param name="typeOfEntity">the type of the entity to get the datasource for</param>
		/// <returns>the requested datasource</returns>
		public IDataSource GetQueryableForEntity(int typeOfEntity)
		{
			IDataSource toReturn = null;
			switch((CARMSData.EntityType)typeOfEntity)
			{
				case CARMSData.EntityType.ActionEntity:
					toReturn = this.Action;
					break;
				case CARMSData.EntityType.ActionGridColumnEntity:
					toReturn = this.ActionGridColumn;
					break;
				case CARMSData.EntityType.ColumnToActionEntity:
					toReturn = this.ColumnToAction;
					break;
				case CARMSData.EntityType.CompanyEntity:
					toReturn = this.Company;
					break;
				case CARMSData.EntityType.ConfigurationEntity:
					toReturn = this.Configuration;
					break;
				case CARMSData.EntityType.CountryEntity:
					toReturn = this.Country;
					break;
				case CARMSData.EntityType.CustomerEntity:
					toReturn = this.Customer;
					break;
				case CARMSData.EntityType.DepartmentEntity:
					toReturn = this.Department;
					break;
				case CARMSData.EntityType.DictionaryEntity:
					toReturn = this.Dictionary;
					break;
				case CARMSData.EntityType.DictionaryCategoryEntity:
					toReturn = this.DictionaryCategory;
					break;
				case CARMSData.EntityType.G100Entity:
					toReturn = this.G100;
					break;
				case CARMSData.EntityType.G102Entity:
					toReturn = this.G102;
					break;
				case CARMSData.EntityType.G103Entity:
					toReturn = this.G103;
					break;
				case CARMSData.EntityType.G131Entity:
					toReturn = this.G131;
					break;
				case CARMSData.EntityType.G132Entity:
					toReturn = this.G132;
					break;
				case CARMSData.EntityType.GlossaryEntity:
					toReturn = this.Glossary;
					break;
				case CARMSData.EntityType.LogEntity:
					toReturn = this.Log;
					break;
				case CARMSData.EntityType.MailEntity:
					toReturn = this.Mail;
					break;
				case CARMSData.EntityType.MailTaskEntity:
					toReturn = this.MailTask;
					break;
				case CARMSData.EntityType.MessageEntity:
					toReturn = this.Message;
					break;
				case CARMSData.EntityType.ReportCategoryEntity:
					toReturn = this.ReportCategory;
					break;
				case CARMSData.EntityType.ReportCategoryToTemplateEntity:
					toReturn = this.ReportCategoryToTemplate;
					break;
				case CARMSData.EntityType.ReportFlowEntity:
					toReturn = this.ReportFlow;
					break;
				case CARMSData.EntityType.ReportHeaderEntity:
					toReturn = this.ReportHeader;
					break;
				case CARMSData.EntityType.ReportOneEntity:
					toReturn = this.ReportOne;
					break;
				case CARMSData.EntityType.ReportPropertyEntity:
					toReturn = this.ReportProperty;
					break;
				case CARMSData.EntityType.ReportStatusToButtonEventEntity:
					toReturn = this.ReportStatusToButtonEvent;
					break;
				case CARMSData.EntityType.ReportTwoEntity:
					toReturn = this.ReportTwo;
					break;
				case CARMSData.EntityType.ReportValueEntity:
					toReturn = this.ReportValue;
					break;
				case CARMSData.EntityType.RoleEntity:
					toReturn = this.Role;
					break;
				case CARMSData.EntityType.RoleActionEntity:
					toReturn = this.RoleAction;
					break;
				case CARMSData.EntityType.SalaryLevelEntity:
					toReturn = this.SalaryLevel;
					break;
				case CARMSData.EntityType.TemplateEntity:
					toReturn = this.Template;
					break;
				case CARMSData.EntityType.TemplateToReportCategoryEntity:
					toReturn = this.TemplateToReportCategory;
					break;
				case CARMSData.EntityType.UserEntity:
					toReturn = this.User;
					break;
				case CARMSData.EntityType.UserActionEntity:
					toReturn = this.UserAction;
					break;
				case CARMSData.EntityType.UserPermissionEntity:
					toReturn = this.UserPermission;
					break;
				case CARMSData.EntityType.UserRoleEntity:
					toReturn = this.UserRole;
					break;
				default:
					toReturn = null;
					break;
			}
			return toReturn;
		}

		/// <summary>returns the datasource to use in a Linq query when targeting ActionEntity instances in the database.</summary>
		public DataSource<ActionEntity> Action
		{
			get { return new DataSource<ActionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ActionGridColumnEntity instances in the database.</summary>
		public DataSource<ActionGridColumnEntity> ActionGridColumn
		{
			get { return new DataSource<ActionGridColumnEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ColumnToActionEntity instances in the database.</summary>
		public DataSource<ColumnToActionEntity> ColumnToAction
		{
			get { return new DataSource<ColumnToActionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CompanyEntity instances in the database.</summary>
		public DataSource<CompanyEntity> Company
		{
			get { return new DataSource<CompanyEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ConfigurationEntity instances in the database.</summary>
		public DataSource<ConfigurationEntity> Configuration
		{
			get { return new DataSource<ConfigurationEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CountryEntity instances in the database.</summary>
		public DataSource<CountryEntity> Country
		{
			get { return new DataSource<CountryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CustomerEntity instances in the database.</summary>
		public DataSource<CustomerEntity> Customer
		{
			get { return new DataSource<CustomerEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DepartmentEntity instances in the database.</summary>
		public DataSource<DepartmentEntity> Department
		{
			get { return new DataSource<DepartmentEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DictionaryEntity instances in the database.</summary>
		public DataSource<DictionaryEntity> Dictionary
		{
			get { return new DataSource<DictionaryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DictionaryCategoryEntity instances in the database.</summary>
		public DataSource<DictionaryCategoryEntity> DictionaryCategory
		{
			get { return new DataSource<DictionaryCategoryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting G100Entity instances in the database.</summary>
		public DataSource<G100Entity> G100
		{
			get { return new DataSource<G100Entity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting G102Entity instances in the database.</summary>
		public DataSource<G102Entity> G102
		{
			get { return new DataSource<G102Entity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting G103Entity instances in the database.</summary>
		public DataSource<G103Entity> G103
		{
			get { return new DataSource<G103Entity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting G131Entity instances in the database.</summary>
		public DataSource<G131Entity> G131
		{
			get { return new DataSource<G131Entity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting G132Entity instances in the database.</summary>
		public DataSource<G132Entity> G132
		{
			get { return new DataSource<G132Entity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting GlossaryEntity instances in the database.</summary>
		public DataSource<GlossaryEntity> Glossary
		{
			get { return new DataSource<GlossaryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting LogEntity instances in the database.</summary>
		public DataSource<LogEntity> Log
		{
			get { return new DataSource<LogEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting MailEntity instances in the database.</summary>
		public DataSource<MailEntity> Mail
		{
			get { return new DataSource<MailEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting MailTaskEntity instances in the database.</summary>
		public DataSource<MailTaskEntity> MailTask
		{
			get { return new DataSource<MailTaskEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting MessageEntity instances in the database.</summary>
		public DataSource<MessageEntity> Message
		{
			get { return new DataSource<MessageEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportCategoryEntity instances in the database.</summary>
		public DataSource<ReportCategoryEntity> ReportCategory
		{
			get { return new DataSource<ReportCategoryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportCategoryToTemplateEntity instances in the database.</summary>
		public DataSource<ReportCategoryToTemplateEntity> ReportCategoryToTemplate
		{
			get { return new DataSource<ReportCategoryToTemplateEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportFlowEntity instances in the database.</summary>
		public DataSource<ReportFlowEntity> ReportFlow
		{
			get { return new DataSource<ReportFlowEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportHeaderEntity instances in the database.</summary>
		public DataSource<ReportHeaderEntity> ReportHeader
		{
			get { return new DataSource<ReportHeaderEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportOneEntity instances in the database.</summary>
		public DataSource<ReportOneEntity> ReportOne
		{
			get { return new DataSource<ReportOneEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportPropertyEntity instances in the database.</summary>
		public DataSource<ReportPropertyEntity> ReportProperty
		{
			get { return new DataSource<ReportPropertyEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportStatusToButtonEventEntity instances in the database.</summary>
		public DataSource<ReportStatusToButtonEventEntity> ReportStatusToButtonEvent
		{
			get { return new DataSource<ReportStatusToButtonEventEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportTwoEntity instances in the database.</summary>
		public DataSource<ReportTwoEntity> ReportTwo
		{
			get { return new DataSource<ReportTwoEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportValueEntity instances in the database.</summary>
		public DataSource<ReportValueEntity> ReportValue
		{
			get { return new DataSource<ReportValueEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RoleEntity instances in the database.</summary>
		public DataSource<RoleEntity> Role
		{
			get { return new DataSource<RoleEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RoleActionEntity instances in the database.</summary>
		public DataSource<RoleActionEntity> RoleAction
		{
			get { return new DataSource<RoleActionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting SalaryLevelEntity instances in the database.</summary>
		public DataSource<SalaryLevelEntity> SalaryLevel
		{
			get { return new DataSource<SalaryLevelEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting TemplateEntity instances in the database.</summary>
		public DataSource<TemplateEntity> Template
		{
			get { return new DataSource<TemplateEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting TemplateToReportCategoryEntity instances in the database.</summary>
		public DataSource<TemplateToReportCategoryEntity> TemplateToReportCategory
		{
			get { return new DataSource<TemplateToReportCategoryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserEntity instances in the database.</summary>
		public DataSource<UserEntity> User
		{
			get { return new DataSource<UserEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserActionEntity instances in the database.</summary>
		public DataSource<UserActionEntity> UserAction
		{
			get { return new DataSource<UserActionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserPermissionEntity instances in the database.</summary>
		public DataSource<UserPermissionEntity> UserPermission
		{
			get { return new DataSource<UserPermissionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserRoleEntity instances in the database.</summary>
		public DataSource<UserRoleEntity> UserRole
		{
			get { return new DataSource<UserRoleEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		#region Class Property Declarations
		/// <summary> Gets / sets the ITransaction to use for the queries created with this meta data object.</summary>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public ITransaction TransactionToUse
		{
			get { return _transactionToUse;}
			set { _transactionToUse = value;}
		}

		/// <summary>Gets or sets the custom function mappings to use. These take higher precedence than the ones in the DQE to use</summary>
		public FunctionMappingStore CustomFunctionMappings
		{
			get { return _customFunctionMappings; }
			set { _customFunctionMappings = value; }
		}
		
		/// <summary>Gets or sets the Context instance to use for entity fetches.</summary>
		public Context ContextToUse
		{
			get { return _contextToUse;}
			set { _contextToUse = value;}
		}
		#endregion
	}
}